libxl: Make an internal function explicitly check existence of expected paths
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Thu, 6 Dec 2012 10:19:08 +0000 (10:19 +0000)
committerGeorge Dunlap <george.dunlap@eu.citrix.com>
Thu, 6 Dec 2012 10:19:08 +0000 (10:19 +0000)
commitd7942d1dbe5d98cef71c00c51f2826eefb9273d0
tree3a34cc02873e6c66c59a5f4830ce0dacdc9893f9
parentf60d158a02165aac0eb824106f0655589b4f683e
libxl: Make an internal function explicitly check existence of expected paths

libxl__device_disk_from_xs_be() was failing without error for some
missing xenstore nodes in a backend, while assuming (without checking)
that other nodes were valid, causing a crash when another internal
error wrote these nodes in the wrong place.

Make this function consistent by:
* Checking the existence of all nodes before using
* Choosing a default only when the node is not written in device_disk_add()
* Failing with log msg if any node written by device_disk_add() is not present
* Returning an error on failure
* Disposing of the structure before returning using libxl_device_disk_displose()

Also make the callers of the function pay attention to the error and
behave appropriately.  In the case of libxl__append_disk_list_of_type(),
this means only incrementing *ndisks as the disk structures are
successfully initialized.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.c